<%@ page contentType="text/html;charset=iso8859_1" language="java" %>
<%@page import="java.sql.Connection,java.sql.PreparedStatement,java.sql.ResultSet,
				java.sql.SQLException,git.etl.Dao"%>

<jsp:useBean id="oLogon" class="git.bankview.wl.bean.LogonBean" scope="session" />
<% oLogon.setLogon(false); %>
<jsp:setProperty name="oLogon" property="username" />
<jsp:setProperty name="oLogon" property="remoteHost" value="<%=request.getRemoteAddr()%>" />
<jsp:useBean id="doUsers" scope="page" class="git.bankview.wl.auth.userGroups.UsersBean"/>
<jsp:setProperty name="doUsers" property="requestObj" value="<%=request %>" />
<%
	String pwd = request.getParameter("password");
	try
	{
		doUsers.loginCheck(oLogon.getUsername(),pwd);
		oLogon.setLogon(true);
		oLogon.writeJournal("LOGIN", "OK");
	}
	catch(Exception e)
	{
		oLogon.setLogon(false);
		oLogon.writeJournal("LOGIN", "FAILED - " + e.getMessage());
		throw e;
	}
   //response.sendRedirect(request.getParameter("redirect"));
   //modify by wan.yang 2010-10-25
//   response.sendRedirect("/bidevapp/main.do?action=mainPage&userId="+oLogon.getUsername());
   
   //add by wan.yang 2010-10-25
   
   String sql = "select firstpage from infouser where userid=?";
   String userid = oLogon.getUsername().trim();
   String firstPage = "";
	
	Connection conn = null;
	PreparedStatement psmt = null;
	ResultSet rs = null;
	
	try{
		conn = Dao.getCogdbConnection();
		psmt = conn.prepareStatement(sql);
		psmt.setString(1,userid);
		rs = psmt.executeQuery();
		while(rs.next()){
			firstPage = rs.getString("firstpage");
		}
	}catch(SQLException e){
		e.printStackTrace();
	}finally{
		if (null != rs) {
			try {
				rs.close();
			} catch (Exception e) {}
		}
		
		if (null != psmt) {
			try {
				psmt.close();
			} catch (Exception e) {}
		}
		
		if (null != conn) {
			try {
				conn.close();
			} catch (Exception e) {}
		}
	}
	System.out.println("firstpage--->"+firstPage);
	if("1".equals(firstPage)){
	//new net door page
		response.sendRedirect("/bidevapp/homePage1/doorPage.jsp");
	}else{
	//old frame page
		response.sendRedirect("/bidevapp/main.do?action=mainPage&userId="+oLogon.getUsername());
	}
%>

